//
//  HeavyRotationViewController.m
//  HeavyRotation
//
//  Created by Xia Yong on 13-1-18.
//  Copyright (c) 2013年 Xia Yong. All rights reserved.
//

#import "HeavyRotationViewController.h"

@interface HeavyRotationViewController ()

- (void)orientationChanged:(NSNotification *) note;
- (BOOL)shouldAutorotate;

@end

@implementation HeavyRotationViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// 获取UIDevice对象
	UIDevice *device = [UIDevice currentDevice];
    // 命令UIDevice对象开启加速感应器并监视方向变化
    [device beginGeneratingDeviceOrientationNotifications];
    // 获取应用程序的NSNotificationCenter对象
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    // 将self注册为观察者
    [nc addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:device];
}


- (void)orientationChanged:(NSNotification *) note {
    NSLog(@"orientationChanged: %d", [[note object] orientation]);
}

- (BOOL)shouldAutorotate {
    // 设置不支持转屏
    return YES;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
